<template>
	<view class="">
		<view class=" flex align-center">
			<view class="u-padding-30">
				{{title}}
			</view>
		</view>
		<view class=" bg-fff">
			<view class="u-padding-30 flex align-center u-border-bottom">
				<text class="fs-30 color-333 margin-right-24 w25">{{title}}号</text>
				<input class="fs-30 color-999" type="text" :placeholder="`请输入信息`" v-model="info.wechat_num" />
			</view>
			<view class="u-padding-30 flex align-center u-border-bottom">
				<text class="fs-30 color-333 margin-right-24 w25">
					{{title}}名</text>
				<input class="fs-30 color-999" type="text" :placeholder="`请输入信息`" v-model="info.wechat_name" />
			</view>
		</view>
		<view class="mr56 h86 paybtn" @tap="submit()">
			确认
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info: {
					wechat_num: '',
					wechat_name: '',
				},
				type: '',
				title: ''
			};
		},
		onLoad(opt) {
			console.log(11);
			let userInfo = uni.getStorageSync('userInfo') || ''
			// this.info = userInfo
			console.log(uni.getStorageSync('userInfo'));
			this.type = opt.type
			if (this.type == 1) {
				this.title = '微信'
				if (userInfo) {
					this.info.wechat_num = userInfo.wechat_num || ''
					this.info.wechat_name = userInfo.wechat_name || ''
				}
			} else {
				this.title = '支付宝'
				if (userInfo) {
					this.info.wechat_num = userInfo.alipay_num || ''
					this.info.wechat_name = userInfo.alipay_name || ''
				}
			}
			
		},
		methods: {

			submit() {
				if (!this.info.wechat_num) {
					return this.$u.toast(`请填写` + this.title + `号`);
				}
				if (!this.info.wechat_name) {
					return this.$u.toast(`请填写` + this.title + `名`);
				}
				let api = ''
				if (this.type == 1) {
					api = 'proWechat'
				} else if (this.type == 2) {
					api = 'proAlipay'
				}
				console.log(api)
				this.$api[api](this.info).then(res => {
					this.$u.toast(res.msg);
					if (res.code == 1) {
						setTimeout(() => {
							uni.navigateBack()
						}, 1000)
					}
				})
			},
		}
	};
</script>

<style>
	page {
		background-color: #FFFFFF;
	}

	.w25 {
		width: 25% !important;
	}

	.paybtn {
		width: 80%;
		position: fixed;
		left: 50%;
		bottom: 40rpx;
		transform: translateX(-50%);
		text-align: center;
		line-height: 86rpx;
		background: #1385FF;
		border-radius: 10rpx;
		color: #FFFFFF;
		z-index: 99;
	}
</style>
